import 'package:flutter/material.dart';
import 'package:core_package/core_package.dart';
import 'package:flutter_app_unionad/model/promotion_materials_model.dart';
import 'package:flutter_app_unionad/model/share_pic_model.dart';
import 'package:flutter_app_unionad/request/partner_ship_request.dart';
import 'package:flutter_app_unionad/request/promotion_request.dart';
import 'package:flutter_app_unionad/ui/basice/my_button.dart';
import 'package:flutter_app_unionad/ui/partnership/partnership_page.dart';

//不是合伙人
class UnPartnershipWidget extends StatefulWidget {
  final PartnershipPageDelegate? delegate;

  const UnPartnershipWidget({Key? key, this.delegate}) : super(key: key);

  @override
  _UnPartnershipWidgetState createState() => _UnPartnershipWidgetState();
}

class _UnPartnershipWidgetState extends State<UnPartnershipWidget> {
  List<PromotionMaterialsModel>? list;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    PromotionRequest.getListByType(type: 3).then((value) {
      if (mounted)
        setState(() {
          list = value;
        });
    });
  }

  @override
  Widget build(BuildContext context) {
    if (list == null) {
      return ProgressDialog.showFirstLoading();
    }
    if (list?.length == 0) {
      return Container();
    }
    return Column(
      children: [
        MySizeBox(height: 21),
        Text(
          "招募合伙人",
          style: TextStyle(
            color: MyColors.formHex("#272727ff"),
            fontSize: MyFont.font20,
            fontWeight: MyFontWeight.bold,
          ),
        ),
        MySizeBox(height: 15),
        Text(
          "招募合伙人",
          style: TextStyle(
            color: MyColors.formHex("#272727ff"),
            fontSize: MyFont.font11,
            fontWeight: MyFontWeight.light,
          ),
        ),
        MySizeBox(height: 25),
        Expanded(child: buildContent()),
        MySizeBox(height: 10),
      ],
    );
  }

  Widget buildContent() {
    return Container(
      padding: EdgeInsets.all(20.px),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(5.px),
      ),
      child: SingleChildScrollView(
        child: Column(
          children: [
            ShowPicWidget(
              list?[0].coverImg ?? '',
              // height: 433.px,
              width: double.infinity,
              fit: BoxFit.fitWidth,
              showDefault: false,
            ),
            MySizeBox(height: 44),
            MyButton(
              title: "成为合伙人",
              onTap: () {
                if (widget.delegate != null) {
                  widget.delegate!.becomePartnership();
                }
              },
            )
          ],
        ),
      ),
    );
  }
}
